<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<form action="" method="">
			<table border="1" cellspacing="0" cellpadding="10px" id="table1">
				<tr>
					<td></td>
					<td>姓名</td>
					<td>性别</td>
					<td>年龄</td>
					<td>家庭住址</td>
				</tr>
				<tr>
					<td><input type="checkbox" name="nan" id="" value="1"/></td>
					<td>小明1</td>
					<td>男</td>
					<td>20</td>
					<td>福建省新罗区</td>
				</tr>
				<tr>
					<td><input type="checkbox" name="nv" id="" value="2"/></td>
					<td>小明2</td>
					<td>女</td>
					<td>20</td>
					<td>福建省新罗区</td>
				</tr>
				<tr>
					<td><input type="checkbox" name="nan" id="" value="3" /></td>
					<td>小明3</td>
					<td>男</td>
					<td>19</td>
					<td>福建省新罗区</td>
				</tr>
				<tr>
					<td><input type="checkbox" name="nv" id="" value="4" /></td>
					<td>小明4</td>
					<td>女</td>
					<td>19</td>
					<td>福建省新罗区</td>
				</tr>
				<tr>
					<td><input type="checkbox" name="nan" id="" value="5" /></td>
					<td>小明5</td>
					<td>男</td>
					<td>21</td>
					<td>福建省新罗区</td>
				</tr>
			</table>
			<input type="checkbox" name="" id="allselect" value="11" onclick="select1()"/>全选
			<input type="checkbox" name="" id="nanselect" value="22" onclick="nan1()"/>全男
			<input type="checkbox" name="" id="nvselect" value="33" onclick="nv1()"/>全女
			<button type="button">删除</button>
		</form>
	</body>
	<script type="text/javascript">
			function select1(){
				var allsel=document.getElementById('allselect');
				var tab=document.getElementById('table1');
				var selects = tab.getElementsByTagName('input');
				for(var i=0;i<selects.length;i++){
					 selects[i].checked=allsel.checked;
					
				}
			}
			function nan1(){
				var nansel=document.getElementById('nanselect');
				var tab=document.getElementById('table1');
				var selects = tab.getElementsByTagName('input');
				for(var i=0;i<selects.length;i++){
					if(selects[i].name=="nan"){
						selects[i].checked=nansel.checked;
					}
					
				}
			}
			function nv1(){
				var nvsel=document.getElementById('nvselect');
				var tab=document.getElementById('table1');
				var selects = tab.getElementsByTagName('input');
				for(var i=0;i<selects.length;i++){
					if(selects[i].name=="nv"){
						selects[i].checked=nvsel.checked;
					}
					
				}
			}
	
	</script>
</html>
